package com.asiainfo.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.asiainfo.bean.AuthorityBean;
import com.asiainfo.common.mapper.BaseMapper;
import com.asiainfo.common.service.BaseService;
import com.asiainfo.dao.AuthorityMapper;
import com.asiainfo.service.AuthorityService;

/**
 * 资源服务实现
 * @author luhf
 * @date 2013-1-19 下午10:26:13
 */
@Service("impl.authorityServiceImpl")
public class AuthorityServiceImpl extends BaseService<AuthorityBean> implements AuthorityService{
	
	@SuppressWarnings("rawtypes")
	private BaseMapper mapper;

	@Autowired
	@Qualifier("mapper.authorityMapper")
	private AuthorityMapper authorityMapper;

	@Override
	public List<AuthorityBean> getAuthorityList(){
		return getListAll();
	}
	
	@Override
	public Map<String,Object> getAuthorityList(int rows,int page){
		return getListByPage(rows,page);
	}

	@Override
	public Map<String,Object> addAuthority(AuthorityBean authorityBean){
		Map<String,Object> map=new HashMap<String,Object>(1);
		try{
			authorityMapper.insertAuthority(authorityBean);
			map.put("success","true");
		}catch(Exception e){
			e.printStackTrace();
		}
		return map;
	}

	@SuppressWarnings("rawtypes")
	@Override
	public BaseMapper getMapper(){
		if(mapper==null)
			mapper=authorityMapper;//默认mapper
		return mapper;
	}

	@SuppressWarnings("rawtypes")
	@Override
	public void setMapper(BaseMapper mapper){
		this.mapper=mapper;
	}

}
